# 导包
import requests

# url = "http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login&t=0.9112008475406435"
# header = {"Content-Type": "application/x-www-form-urlencoded"}
# body = {"username": "17788888888", "password": "123456", "verify_code": "8888"}
# resp = requests.post(url=url, headers=header, data=body)
# print("响应状态码=", resp.status_code)
# print("响应结果:",resp.json())
# 设置url # 断言
# class Test:
#     def test_login(self):
#         url = "http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login&t=0.9112008475406435"
#         header = {"Content-Type":"application/x-www-form-urlencoded"}
#         body = {"username": "17788888888", "password": "123456", "verify_code": "8888"}
#         resp = requests.post(url=url,headers=header,data=body)
#         print("响应状态码=",resp.status_code)
#         print(type(resp))
#         print("resp=",resp.json()['msg'])
#         msg = '验证码错误'
#         assert msg == resp.json()['msg']

# 表单用json, html用text

url2 = "http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login&t=0.9112008475406435"
header = {"Content-Type":"application/x-www-form-urlencoded"}
body = {"username": "17788888888", "password": "123456", "verify_code": "8888"}
resp = requests.post(url=url2,headers=header,data=body)
print(resp.status_code)
print(resp.json())





